<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function ajax(data) {
            if (typeof data === 'string') {
                // 说明提交的是查询字符串
                console.log('提交的是查询字符串');
            } else if (data instanceof FormData) {
                // 说明提交的是FormData对象
            } else if (data instanceof Object) {
                // 说明提交的是字面量对象
                console.log('提交的是字面量对象');
            }
        }

        // 1. 调用函数，传递查询字符串
        // ajax('bookname=aa&author=bb&publisher=cc')
        
        // 2. 调用函数，传递JS字面量对象
        // ajax({ bookname: 'aa', author: 'bb', publisher: 'cc' })

        // 3. 调用函数，传递FormData对象
        let fd = new FormData()
        fd.append('bookname', 'aa')
        fd.append('author', 'bb')
        fd.append('publisher', 'cc')
    </script>
</body>

</html>